<%--
  Created by IntelliJ IDEA.
  User: 谢兴鑫
  Date: 2022/4/26
  Time: 下午 02:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>申请维修</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>

</head>
<script>
    layui.use(['form', 'laydate', 'layer'], function () {
        var form = layui.form, laydate = layui.laydate, layer = layui.layer;
        form.verify({
            v_notallnum:function (val,item) {
                if (/^\d+\d+\d$/.test(val)){
                    return "不能为全数字"
                }
            },
            v_pass:[
                /^[\S]{0,20}$/,
                '长度不能超过20个字'
            ],
        });
        //监听表单提交
        form.on('submit(formBtn)', function () {
            var formData = new FormData($("#form1")[0]);
            $.ajax({
                url:'${pageContext.request.contextPath}/holidaystudent/weixiuadd',
                type : 'POST',
                data : formData,
                cache: false,
                async: false,
                processData : false,  //必须false才会避开jQuery对 formdata 的默认处理
                contentType : false,  //必须false才会自动加上正确的Content-Type
                mimeType:"multipart/form-data",
                success:function(data){
                    layer.msg('申请成功！',{icon:6,offset:"auto",time:2000});//提示框
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name);
                        // parent.layer.close(index);//关闭弹出层
                        location.reload();//重新加载父页面表格
                    }, 2100);
                }
            })
            return false;
        });


    });

</script>
<body><br/>

<form class="layui-form" id="form1">

<%--    设备名--%>
    <div class="layui-form-item">
        <label class="layui-form-label">维修设备名:</label>
        <div class="layui-input-inline">
            <input type="text" name="equipmentType" class="layui-input" placaholder="请输入维修设备名称" lay-verify="required|v_notallnum|v_pass"/>
        </div>
        <span style="font-size: 10px;color: red">※</span>
    </div>

<%--    默认状态：未完成--%>
    <input type="hidden" value="0" name="status">

<%--    班级--%>
    <input type="hidden"  name="classes" value="${sessionScope.STU.clazz}">

<%--号主申请--%>
<%--    ${sessionScope.STUID}--%>
    <input type="hidden"  name="student" value="${sessionScope.STUID}">
<%--    备注--%>
    <div class="layui-form-item">
        <label class="layui-form-label">备注:</label>
        <div class="layui-input-inline">
            <input type="text" name="remark" class="layui-input" placaholder="请输入备注"/>
        </div>
    </div>

<%--    部门--%>
    <div class="layui-form-item">
        <label class="layui-form-label">部门:</label>
        <div class="layui-input-inline">
            <select name="depId">
                <c:forEach items="${bmlist}" var="e">
                    <option value="${e.depid}">${e.depName}</option>
                </c:forEach>
            </select>
        </div>
    </div>

<%--    申请--%>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <button class="layui-btn layui-btn-normal" id="formbtn" type="button" lay-submit lay-filter="formBtn">申请</button>

            <button id="reset" type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>



</form>
<script>
</script>
</body>
</html>